package sql.db;

import java.util.*;

public class AliasTable {

	public ArrayList<String> orinames = null;
	public ArrayList<String> newnames = null;

	public AliasTable() {
		super();
		orinames = new ArrayList<String>();
		newnames = new ArrayList<String>();
	}
	
	public void put(String oriname)
	{
		put(oriname, oriname);
	}

	public void put(String oriname, String newname)
	{
		orinames.add(oriname.toLowerCase());
		newnames.add(newname.toLowerCase());
	}
	
	public String get(String newname)
	{
		if (!newnames.contains(newname.toLowerCase()))
			return new String("");
		
		String oriname = null;
		for (int i = 0 ; i < newnames.size() ; i++) {
			if (newname.toLowerCase().equals(newnames.get(i))) {
				if (oriname != null)
					return null;
				oriname = orinames.get(i);
			}
		}
		
		return oriname;
	}
	
	public String getOriName(int idx)
	{
		if (orinames.size() < idx+1)
			return null;
		
		return orinames.get(idx);
	}
	
	public String getNewName(int idx)
	{
		if (newnames.size() < idx+1)
			return null;
		
		return newnames.get(idx);
	}
	
	public int size()
	{
		return orinames.size();
	}
}
